﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Collections;
using System.Xml.Linq;

public partial class TestDemo_Ajax_jtemplate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //使页面的缓存失效，每次都需要获取新页面
        //Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);

        if (!IsPostBack)
        {

        }
    }

    [WebMethod]
    public static IEnumerable GetFeedburnerItems(int Count)
    {
        XDocument feedXML =
            XDocument.Load("http://news.baidu.com/n?cmd=1&class=civilnews&tn=rss");

        var feeds =
          from feed in feedXML.Descendants("item")
          select new
          {
              Date = DateTime.Parse(feed.Element("pubDate").Value)
                             .ToShortDateString(),
              Title = feed.Element("title").Value,
              Link = feed.Element("link").Value,
              Description = feed.Element("description").Value
          };

        return feeds.Take(Count);
    }

    [WebMethod]
    public static string GetMessage()
    {
        return DateTime.Now.ToString();
    }
}